#include "stdio.h"

int main(int argc,char *argv[])
{
	int i;
	int max;
	int value = 1;
	int x,y;
	int arry[9][9] = {0};
	int up,down,left,right;
	up = left = 0;
	
	while(scanf("%d",&max)){
		if( max < 2 || max > 9){
			printf("Please input a number from 2 to 9\n");
		}
		else{
			break;
		}
	}
	
	down = right = max - 1;

	while(1){
		for(i = left;i <= right;i++){
			arry[up][i] = value++;
		}
		if( ++up > down ){
			break;
		}

		for(i = up;i <= down;i++){
			arry[i][right] = value++;
		}
		if( --right < left ){
			break;
		}

		for(i = right;i >= left;i--){
			arry[down][i] = value++;
		}
		if( --down < up ){
			break;
		}

		for(i = down;i >= up;i--){
			arry[i][left] = value++;
		}
		if( ++left > right ){
			break;
		}
	}
		
	for (x = 0; x < max; x++){
		for (y = 0; y < max; y++){
			printf("%d\t",arry[x][y]);
		}
		printf("\n");
	}
	
	return 0;
}
